package com.xbongbong.paas.factory;

import com.xbongbong.paas.abstracts.AbstractLowCodeHandlerFieldService;
import com.xbongbong.paas.constant.PaasConstant;
import com.xbongbong.paas.enums.FieldTypeEnum;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * @author 吴峰
 * @date 2021/03/18 13:56
 */
public class LowCodeHandlerFieldFactory {

    public static final Map<Integer, AbstractLowCodeHandlerFieldService> LOW_CODE_HANDLER_FIELD = new ConcurrentHashMap<>(PaasConstant.DEFAULT_INITIAL_CAPACITY);

    /**
     * 工厂
     * @param fieldType
     * @return
     */
    public static AbstractLowCodeHandlerFieldService getServiceExecute(Integer fieldType) {

        if (LOW_CODE_HANDLER_FIELD.containsKey(fieldType)) {
            return LOW_CODE_HANDLER_FIELD.get(fieldType);

        }
        // 这是个默认的构造工厂；
        return LOW_CODE_HANDLER_FIELD.get(FieldTypeEnum.TEXT.getType());
    }
}
